﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Xwang.Task.WebUI.Controllers
{
    /// <summary>
    /// 部门相关控制器
    /// </summary>
    public class DepController : AppController
    {
        private IBll.IDepInfoService DepInfoService { get; set; }
        // GET: /Dep/

        /// <summary>
        /// 部门列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetList()
        {
            try
            {
                var deps = DepInfoService.LoadEntities(t => true);
                return Json(new
                {
                    success = true,
                    msg = "",
                    data = from dep in deps
                           select new
                           {
                               dep.DepName,
                               dep.KeyId
                           }
                }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(new
                {
                    success = false,
                    msg = ex.Message
                }, JsonRequestBehavior.AllowGet);
            }

        }
    }
}
